package com.taldh.utils.beancopy;

import net.sf.cglib.beans.BeanCopier;
import net.sf.cglib.core.DebuggingClassWriter;

import java.util.Date;

public class BeanCopyTest {

    public static void main(String[] args) {

        ChildDto dto = new ChildDto();
        dto.setId(1);
        dto.setCrateTime(new Date());
        dto.setName("ydonghao");
        dto.setGrade(Grade.Grade1);

        Child child = new Child();

        System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, "/Users/donghaoyuan/workspaces/IdeaProjects/leetcode/src/main/java/com/taldh/utils/beancopy");
        BeanCopier bc = BeanCopier.create(ChildDto.class, Child.class,
                false);

        bc.copy(dto, child, null);

        System.out.println(child);
        System.out.println(child.getId());
        Child copy = ListBeanCopy.copy2(dto, Child.class);
        System.out.println(copy);
        System.out.println(ListBeanCopy.copy2(copy, ChildDto.class));
    }

}
